package com.android.hq.ganktoutiao.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.hq.ganktoutiao.R;

import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

/**
 * Created by Administrator on 2017/5/12.
 */
public class ZhuCeActivity extends Activity {

    EditText zhanghao;
    EditText mima;
    Button zhaohui;
    Button denglu;
    Button zhuce;
//    Handler handler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.recycler_item_dneglu);

        //  找到各自的id
        zhanghao = (EditText) findViewById(R.id.edit_name);
        mima = (EditText) findViewById(R.id.edit_password);
        zhaohui = (Button) findViewById(R.id.button_zhaohui);
        denglu = (Button) findViewById(R.id.button_denglu);
        zhuce = (Button) findViewById(R.id.button_zhuce);

        //  页面的跳转
        zhaohui.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ZhuCeActivity.this, ZhaoHui.class);
                startActivity(intent);
                finish();
            }
        });

        zhuce.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ZhuCeActivity.this, ZhuCe.class);
                startActivity(intent);
                finish();
            }
        });


        //  点击登录按钮的响应事件
        denglu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name = zhanghao.getText().toString();
                String password = mima.getText().toString();

                if (name.equals(null) || name.equals("") || password.equals(null) || password.equals("")) {
                    Toast.makeText(ZhuCeActivity.this, "帐号或者密码不能为空", Toast.LENGTH_LONG).show();
                } else {
                    //  在此将帐号以及密码发送到服务器进行效验
                }
            }
        });
    }

    public void dengLu (final String username, final String userpassword) {

        new Thread() {
            @Override
            public void run() {
                super.run();

                HttpClient httpClient = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet("http://api.zhaibao.cn/login?" + username + userpassword);

            }
        };
    }
}
